package com.practice.communication.nio;

public class Server {
	
	private static int SERVER_DEFAULT_PORT = 8080;
	
	private static ServerHandler serverHandler;
	
	public static void start() {
		start(SERVER_DEFAULT_PORT);
	}
	
	public static synchronized void start(int port) {
		if (serverHandler != null)
			serverHandler.stop();
		
		serverHandler = new ServerHandler(port);
		new Thread(serverHandler, "Server").start();
	}
	
	public static void main(String[] args) {
		start();
	}

}
